package com.cdsxlc.common.config;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author zhang
 * 数据库配置信息
*/
@Component
@ConfigurationProperties(prefix = "spring.datasource")
@Data
public class DataSourceConfig {

	private String url;

	private String tableSchema;
	
	private String username;
	
	private String password;

	public String getTableSchema() {
		if(StringUtils.isBlank(this.url)){
			throw new RuntimeException("--------------未配置数据库连接--------------");
		}
		int i = url.lastIndexOf("/");
		int j = url.indexOf("?");
		return  url.substring(i + 1, j);
	}

}
